from sqlalchemy import Column, Integer, String, DateTime, BIGINT

from src.config.database import Base

class LaiBase(Base):
    __abstract__ = True
    id = Column(String, primary_key=True)
    create_by = Column(String)
    create_time = Column(DateTime)
    update_by = Column(String)
    update_time = Column(DateTime)
    is_void = Column(Integer)
    loc_time_zone = Column(String)
    version = Column(BIGINT)


class LaiGoods(LaiBase):
    __tablename__: str = "lai_goods"
    __table_args__ = {"schema": "lai"}
    goods_code = Column(String, unique=True, index=True)
    goods_name_cn = Column(String)
    goods_name_en = Column(String)
    goods_brief_introduction = Column(String)
    goods_type = Column(String)
    goods_child_type = Column(String)
    goods_source = Column(String)
    goods_publish_status = Column(String)
    goods_publish_time = Column(DateTime)
    goods_shelve_status = Column(String)
    goods_shelve_time = Column(DateTime)
    icon_url = Column(String)
    owner_project = Column(String)
    owner_tenant = Column(String)
    app_id = Column(String)
    goods_remark = Column(String)
    goods_supplier = Column(String)
    goods_detail_type = Column(String)

    def to_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}